-
Notifications
You must be signed in to change notification settings - Fork 44
in VE use Positron's statementRangeProvider to execute statements
#825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
statementRangeProvider in Positron to execute statements at cursor in VEstatementRangeProvider in Positron to execute statements at cursor
statementRangeProvider in Positron to execute statements at cursorstatementRangeProvider to execute statements at cursor
statementRangeProvider to execute statements at cursorstatementRangeProvider to execute statements
|
I think it's ok to prioritize Positron fixes and leave the VSC fix open for a community PR if there's an approach there that would work. |
|
This is really exciting to see! 🎉 I think there is a bit of improvement to do in terms of where the cursor goes in the visual editor after using these. I see that you said there is some difficulty about setting the cursor position in the visual editor 😬 so it's possible this is a big challenge. Take a look at what I mean:
I also wanted to ask about Python, because I don't see the Python statement range provider being applied, I think? Here is an example to look at:
|
I should be able to set the cursor in the visual editor! The cursor placement problem I was having wasn't visual editor specific, it was virtual doc specific. I will try to improve where the cursor goes after running ctrl+enter. Aside, to elaborate on the virtual doc + cursor problem I was facing: it would be nice to unify execution in the visual editor and the source editor by creating a virtual doc for the current code block, placing a cursor in the virtual doc, and running the relevent execution-at-cursor command in that virtual doc. Unfortunately, I think virtual docs are just files and are not "open" in an editor, so they don't have a cursor associated with them. |
Heard and seen! Thanks for the great example. Indeed the python statement range provider does not seem to be being applied. Also looking at this. |
|
Q: In the source editor, when you A: @sharon-wang found it for me: https://github.com/posit-dev/positron/blob/main/src/vs/workbench/contrib/positronConsole/browser/positronConsoleActions.ts#L428 in the I will copy this logic into the Quarto LSP. Maybe ideally Positron would provide a command like "vscode.executeStatementRangeProviderAndGetNextStatementPosition" that returns both a |
|
I think this was only applying to R documents because of this here:
What happens in the source editor is something like this:
quarto/apps/vscode/src/host/hooks.ts Line 97 in 012d457
quarto/apps/vscode/src/host/hooks.ts Line 161 in 012d457
quarto/apps/vscode/src/host/hooks.ts Line 186 in 012d457
So it goes back and forth a fair amount! I think you will want to set up request forwarding in the You can see what LSP functionality the source editor has with all the "providers" in here: quarto/apps/vscode/src/lsp/client.ts Line 72 in 012d457
|
I don't think my changes to `codeViewSetBlockSelection` work. It seems that `navigateToPos` does not work inside codeMirror? That must be why only "nextline" works in the command - it doesn't use `navigateToPos` it uses a special codeView thing.
New in Positron: pressing ctrl+enter with your cursor in a multiline R statement executes the whole statement.
Before it would only execute the current line.
Note: this fix relies on Positron's
vscode.executeStatementRangeProvidercommand and does not work in VSCode. I was attempting to get this working in VSCode by creating a virtual doc for the code block, setting your cursor in the virtual doc, and running a cell executor on the virtual doc. That did not work out because I don't know how to set your cursor's position in a virtual doc and cell execution commands don't take positions as arguments.addresses posit-dev/positron#7709